﻿Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes
Imports System.Windows.Media.Animation

Namespace CoolnessWidget
	''' <summary>
	''' Interaction logic for CoolView.xaml
	''' </summary>
	Partial Public Class CoolView
		Inherits UserControl
		Public Sub New()
			InitializeComponent()
			previousScore = 25
            mScore = previousScore
        End Sub

        Private previousScore As Integer
        Private mScore As Integer

        Public Property Score As Integer
            Get
                Return mScore
            End Get
            Set(ByVal value As Integer)
                If value >= 0 AndAlso value <= 40 Then
                    previousScore = mScore
                    mScore = value
                    ComputeScore()
                End If
            End Set
        End Property

        Private Sub ComputeScore()
            If previousScore \ 10 <> mScore \ 10 Then
                Dim storyboard = CType(Me.FindResource("ChangeCoolFace"), Storyboard)
                storyboard.SetTargetName(storyboard.Children(0), String.Format("image{0}", previousScore \ 10 + 1))
                storyboard.SetTargetName(storyboard.Children(1), String.Format("image{0}", mScore \ 10 + 1))
                Me.BeginStoryboard(storyboard)
            End If
        End Sub

	End Class
End Namespace
